<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ page import="com.solution.common.config.PublicConfig"%>
<%@ page import="com.solution.admin.home.constants.IndexConstants"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sl" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String basePath = PublicConfig.ROOT_PATH;
	String imgRootURL = PublicConfig.IMG_ROOT_URL;
	String ossImgZoomWX = PublicConfig.OSS_IMG_ZOOM_WX; //微信图片缩放
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>我的积分</title>
<link rel="stylesheet" type="text/css" href="<%=basePath%>/statics_wx/css/main2.css">
<script src="<%=basePath%>/statics/js/webform.js" type="text/javascript"></script>
<script type="text/javascript">
//系统域名 
var rootPath = '<%=basePath%>';
// 系统上传文件展示域名
var imgRootURL = '<%=imgRootURL%>';
// 微信图片缩放
var ossImgZoomWX = '<%=ossImgZoomWX%>';
</script>
<script src="<%=basePath%>/statics_wx/js/jquery.min.js"></script>
<script src="<%=basePath%>/statics_wx/js/js.js"></script>
<script type="text/javascript" src="<%=basePath%>/statics/plugins/layer/layer.js"></script>

</head>
<body style="background: #f3f3f3">
	<c:set var="rootPath" value="<%=basePath%>"></c:set>
	<c:set var="imgRootURL" value="<%=imgRootURL%>"></c:set>
	<c:set var="ossImgZoomWX" value="<%=ossImgZoomWX%>"></c:set>
	<input type="hidden" id="sync_page_num" pname="pageNum" value="${pageBean.currentPage }" />
	<input type="hidden" id="sync_num_per_page" pname="numPerPage" value="${pageBean.numPerPage}" />
	<input type="hidden" id="sync_page_count" pname="pageCount" value="${pageBean.pageCount }" />
	
	<input type="hidden" id="operateFlag" value="${operateFlag }" />
	<div class="jf_part1">
		<ul>
			<li>
				<p>
					<i>总积分</i> <span>${point + costTotalPoint}</span>
				</p> <s></s>
			</li>
			<li>
				<p>
					<i>可用积分</i> <span>${point }</span>
				</p> <s></s>
			</li>
			<li>
				<p>
					<i>已使用</i> <span>${costTotalPoint }</span>
				</p>
			</li>
		</ul>
	</div>
	<div class="jf_nav">
		<ul>
			<li <c:if test="${empty operateFlag }"> class="current" </c:if> >
				<a href="javascript:void(0);" onclick="javascript: $('#operateFlag').val(''); jumpLocalPage();"><p>
					<span>全部</span><em></em>
				</p></a>
			</li>
			<li <c:if test="${operateFlag eq 0 }"> class="current" </c:if> ><a href="javascript:void(0);" onclick="javascript: $('#operateFlag').val('0'); jumpLocalPage();"><p>
						<span>消费</span><em></em>
					</p></a></li>
			<li <c:if test="${operateFlag eq 1 }"> class="current" </c:if> ><a href="javascript:void(0);" onclick="javascript: $('#operateFlag').val('1'); jumpLocalPage();"><p>
						<span>赚取</span><em></em>
					</p></a></li>
		</ul>
	</div>
	<div class="jf_part2">
		<div class="hd">
			<div class="hd_con">
				<div class="left">
					<select id="monthCombo" onchange="javascript: jumpLocalPage();">
						<c:forEach items="${monthList }" var="monthItem">
							<option value="${monthItem.month }" <c:if test="${month == monthItem.month }"> selected="selected" </c:if> >${monthItem.text }</option>
						</c:forEach>
					</select>
					<b>消费 ${costTotalPointCurMonth } 积分<i></i>赚取
						${addTotalPointCurMonth } 积分
					</b>
				</div>
				<div class="right">
					<a href="#"></a>
				</div>
			</div>
		</div>
		<div class="jf_list">
			<c:choose>
				<c:when test="${not empty pointList }">
					<ul id="pointUL">
						<c:forEach items="${pointList }" var="point">
							<!-- 加 -->
							<c:if test="${point.operateFlag eq 1 }">
								<li>
									<div class="boxs_1">
										<div class="pic">
											<img src="${rootPath }/statics_wx/images/order_icon2.png" />
										</div>
										<div class="item-info">
											<h2>
												<c:choose>
													<c:when test="${point.operateType eq 1 }">购买赠送</c:when>
													<c:when test="${point.operateType eq 2 }">签到赠送</c:when>
													<c:when test="${point.operateType eq 3 }">人工赠送</c:when>
													<c:when test="${point.operateType eq 4 }">购买消费</c:when>
													<c:when test="${point.operateType eq 5 }">人工核减</c:when>
													<c:when test="${point.operateType eq 6 }">到期限清零</c:when>
													<c:when test="${point.operateType eq 7 }">撤单退回</c:when>
													<c:when test="${point.operateType eq 8 }">审核不通过退回</c:when>
													<c:when test="${point.operateType eq 9 }">月度订单积分</c:when>
													<c:when test="${point.operateType eq 10 }">注册赠送</c:when>
													<c:when test="${point.operateType eq 11 }">绑定号码赠送</c:when>
													<c:when test="${point.operateType eq 12 }">分享赠送</c:when>
													<c:when test="${point.operateType eq 13 }">抽奖消耗</c:when>
													<c:when test="${point.operateType eq 14 }">积分变更</c:when>
													<c:when test="${point.operateType eq 15 }">退货积分调整</c:when>
													<c:when test="${point.operateType eq 16 }">人工赠送(导入)</c:when>
													<c:when test="${point.operateType eq 17 }">人工核减(导入)</c:when>
													<c:when test="${point.operateType eq 18 }">订单积分扣减</c:when>
													<c:when test="${point.operateType eq 19 }">订单积分增加</c:when>
													<c:when test="${point.operateType eq 20 }">活动赠送</c:when>
													<c:otherwise>其他增加</c:otherwise>
												</c:choose>
											</h2>
											<h3>[${point.adjustReason } ${point.operateUser }]</h3>
											<h4>
												<fmt:formatDate value="${point.operateTime }"
													pattern="yyyy-MM-dd HH:mm:ss" />
											</h4>
											<p class="a2">+ ${point.operatePoint }</p>
										</div>
									</div>
								</li>
							</c:if>
							<!-- 减 -->
							<c:if test="${point.operateFlag eq 0 }">
								<li>
									<div class="boxs_1">
										<div class="pic">
											<img src="${rootPath }/statics_wx/images/order_icon1.png" />
										</div>
										<div class="item-info">
											<h2>
												<c:choose>
													<c:when test="${point.operateType eq 1 }">购买赠送</c:when>
													<c:when test="${point.operateType eq 2 }">签到赠送</c:when>
													<c:when test="${point.operateType eq 3 }">人工赠送</c:when>
													<c:when test="${point.operateType eq 4 }">购买消费</c:when>
													<c:when test="${point.operateType eq 5 }">人工核减</c:when>
													<c:when test="${point.operateType eq 6 }">到期限清零</c:when>
													<c:when test="${point.operateType eq 7 }">撤单退回</c:when>
													<c:when test="${point.operateType eq 8 }">审核不通过退回</c:when>
													<c:when test="${point.operateType eq 9 }">月度订单积分</c:when>
													<c:when test="${point.operateType eq 10 }">注册赠送</c:when>
													<c:when test="${point.operateType eq 11 }">绑定号码赠送</c:when>
													<c:when test="${point.operateType eq 12 }">分享赠送</c:when>
													<c:when test="${point.operateType eq 13 }">抽奖消耗</c:when>
													<c:when test="${point.operateType eq 14 }">积分变更</c:when>
													<c:when test="${point.operateType eq 15 }">退货积分调整</c:when>
													<c:when test="${point.operateType eq 16 }">人工赠送(导入)</c:when>
													<c:when test="${point.operateType eq 17 }">人工核减(导入)</c:when>
													<c:when test="${point.operateType eq 18 }">订单积分扣减</c:when>
													<c:when test="${point.operateType eq 19 }">订单积分增加</c:when>
													<c:when test="${point.operateType eq 20 }">活动赠送</c:when>
													<c:otherwise>其他扣减</c:otherwise>
												</c:choose>
											</h2>
											<h3>[${point.adjustReason } ${point.operateUser }]</h3>
											<h4>
												<fmt:formatDate value="${point.operateTime }"
													pattern="yyyy-MM-dd HH:mm:ss" />
											</h4>
											<p class="a1">- ${point.operatePoint }</p>
										</div>
									</div>
								</li>
							</c:if>
						</c:forEach>
					</ul>
				</c:when>
				<c:otherwise>
					<p style="text-align:center;padding:5px;">
						<label style="font-size: 0.28rem;">暂无记录</label>
					</p>
				</c:otherwise>
			</c:choose>
		</div>
	</div>
</body>

<script type="text/javascript">
/**
 * 跳转页面
 */
function jumpLocalPage() {
	var month = $("#monthCombo").val();
	var operateFlag = $("#operateFlag").val();
	window.location.href = rootPath + "/wx/point/myPoint?month=" + month + "&operateFlag=" + operateFlag;
	
}

//请求数据是否完成
var isComplete = true;
$(window).on( 'scroll', function() {
	if ($(window).scrollTop() >= $(document).height() - $(window).height()) {
		var page_count = $("#sync_page_count").val();
		var current_page = $("#sync_page_num").val();
		if (current_page >= page_count) {
// 			layer.msg('已经到底了', {
// 				time : 500
// 			});
			return false;
		}
		var params = "requestType=sync";
		$("input[id^='sync_']").each(function() {
			if ($(this).attr("pname") == "pageNum") {
				params = params + "&" + $(this).attr("pname") + "=" + (parseInt($(this).val()) + 1);
			} else {
				params = params + "&" + $(this).attr("pname") + "=" + $(this).val();
			}
		});
		params += "&month=" + $("#monthCombo").val();
		params += "&operateFlag=" + $("#operateFlag").val();
		var url = rootPath + "/wx/point/myPoint";
		// 如果上一次请求还未完成，则本次请求忽略
		if(!isComplete) {
			return false;
		}
		// 开始请求
		isComplete = false;
		$.ajax({
				type : "post",
				url : url,
				data : params,
				datatype : "json",
				success : function(jsonObject) {
					var json = $.parseJSON(jsonObject);
					$("#sync_page_num").val(json.currentPage);
					if (json.recordList) {
						// 请求已完成
						isComplete = true;
						var pointHtml = '';
						for (var i = 0; i < json.recordList.length; i++) {
							var point = json.recordList[i];
							/* var className = "";
							if(comment.isLiked > 0) {
								className = " current ";
							} */
							var pointOperateType = '其他';
							if (point.operateType == 1) {
								pointOperateType = "购买赠送";
							} else if (point.operateType == 2) {
								pointOperateType = "签到赠送";
							} else if (point.operateType == 3) {
								pointOperateType = "人工赠送";
							} else if (point.operateType == 4) {
								pointOperateType = "购买消费";
							} else if (point.operateType == 5) {
								pointOperateType = "人工核减";
							} else if (point.operateType == 6) {
								pointOperateType = "到期限清零";
							} else if (point.operateType == 7) {
								pointOperateType = "撤单退回";
							} else if (point.operateType == 8) {
								pointOperateType = "审核不通过退回";
							} else if (point.operateType == 9) {
								pointOperateType = "下单商品预赠积分";
							} else if (point.operateType == 10) {
								pointOperateType = "注册赠送";
							} else if (point.operateType == 11) {
								pointOperateType = "绑定号码赠送";
							} else if (point.operateType == 12) {
								pointOperateType = "分享赠送";
							} else if (point.operateType == 13) {
								pointOperateType = "抽奖消耗";
							} else if (point.operateType == 14) {
								pointOperateType = "积分变更";
							} else if (point.operateType == 15) {
								pointOperateType = "退货积分调整";
							} else if (point.operateType == 16) {
								pointOperateType = "人工赠送(导入)";
							} else if (point.operateType == 17) {
								pointOperateType = "人工核减(导入)";
							} else if (point.operateType == 18) {
								pointOperateType = "订单积分扣减";
							} else if (point.operateType == 19) {
								pointOperateType = "订单积分增加";
							} else if (point.operateType == 20) {
								pointOperateType = "活动赠送";
							} else if (point.operateType == 21) {
								pointOperateType = "推荐下单返现积分";
							} else if (point.operateType == 22) {
								pointOperateType = "邀请用户注册";
							}
							pointHtml += '<li>';
							pointHtml += '	<div class="boxs_1">';
							pointHtml += '		<div class="pic">';
							if (point.operateFlag == 0) {
								pointHtml += '			<img src="' + rootPath + '/statics_wx/images/order_icon1.png" />';
							} else {
								pointHtml += '			<img src="' + rootPath + '/statics_wx/images/order_icon2.png" />';
							}
							pointHtml += '		</div>';
							pointHtml += '		<div class="item-info">';
							pointHtml += '			<h2>' + pointOperateType + '</h2>';
							pointHtml += '			<h3>[' + point.adjustReason + ' ' + point.operateUser + ']</h3>';
							pointHtml += '			<h4>' + formatDateTime(point.operateTime) + '</h4>';
							if (point.operateFlag == 0) {
								pointHtml += '			<p class="a1"> - ' + point.operatePoint + '</p>';
							} else {
								pointHtml += '			<p class="a2"> + ' + point.operatePoint + '</p>';
							}
							pointHtml += '		</div>';
							pointHtml += '	</div>';
							pointHtml += '</li>';
						}
						$("#pointUL").append(pointHtml);
					}
				},
				error : function() {
					layer.msg('查询失败', {
						time : 1000
					});
				}
			});
		}
	});
</script>

</html>